<!--
 * @Date: 2022-07-25 10:44:07
 * @Author: 陶子
 * @LastEditTime: 2023-06-08 13:55:36
 * @FilePath: \jk_one-stop_pc\src\views\managementSettings\systemSet.vue
 * @pageName: 这是--(系统设置)--页面
-->
<template>
  <div>
    <!--  -->
    <crumbs @goBack="goBack" :superiorMenu="['管理设置']" currentMenu="系统设置"></crumbs>
    <div class="cardBox">
      <!-- <div class="cardOne">
        <div class="listBox">
          <div class="itemLeft" @click="changTab(leftIndex)" :class="activeTab==leftIndex?'actvieColor':''" v-for="(leftItem,leftIndex) in leftList" :key="leftIndex">
            {{leftItem}}</div>
        </div>
      </div> -->
      <div class="cardTwo">
        <a-card :bordered="false" size="small" style="height:100%;margin-top:12px">
          <div class="stockBox">
            <div class="itemSet">
              <div class="setTop">
                <div class="topLfet"><span class="titleBorder"></span><span class="titleStyle">出库任务是否启用【标记为出库完成】</span></div>
                <a-switch size="small" v-model="outValue" @change="switchChange('outValue')" />
              </div>
              <div class="setMeddle">如不启用，任务中所有物品的实际出库数量大于等于任务数量时，任务自动变更为已办状态；</div>
              <div class="setBot">启用后，无论实际出库数量是否与任务数量一致，点击【标记为出库完成】，任务自动变更为已办状态。</div>
            </div>
            <div class="itemSet">
              <div class="setTop">
                <div class="topLfet"><span class="titleBorder"></span><span class="titleStyle">入库任务是否启用【标记为入库完成】</span></div>
                <a-switch size="small" v-model="inValue" @change="switchChange('inValue')" />
              </div>
              <div class="setMeddle">如不启用，任务中所有物品的实际入库数量大于等于任务数量时，任务自动变更为已办状态；</div>
              <div class="setBot">启用后，无论实际入库数量是否与任务数量一致，点击【标记为入库完成】，任务自动变更为已办状态。</div>
            </div>
          </div>
          <!-- <div class="stockBox" v-if="activeTab==1">
            <div class="itemSet">
              <div class="setTop">
                <div class="topLfet"><span class="titleBorder"></span><span class="titleStyle">是否启用【工单自动开始】</span></div>
                <a-switch size="small" v-model="autoTurnOnValue" @change="switchChange('autoTurnOnValue')" />
              </div>
              <div class="setMeddle">若启用后，当现实时间到工单的计划开始时间时，生产工单自动开始，工单状态变更为生产中。工人可以进行领料、补料、退料和报工。</div>
              <div class="setBot">若不启用，则必须手动点击开始按钮，生产工单才能开始。</div>
            </div>
          </div> -->
        </a-card>
      </div>
    </div>
  </div>
</template>
<script>
import { querySysSet, sysSetEdit } from '@/api/erpApi'
import crumbs from '@/components/crumbs.vue'
export default {
  components: { crumbs },
  data() {
    return {
      leftList: ['仓库管理','生产管理'],
      activeTab: '0',
      outValue: false,
      inValue: false,
      autoTurnOnValue: false
    }
  },
  created() {
    let outObj = {
      key: 'outboundTaskCompleteBtnFlag',
    }
    this.getSysState(outObj, 'outValue')
    let inObj = {
      key: 'inboundTaskCompleteBtnFlag',
    }
    this.getSysState(inObj, 'inValue')
  },
  methods: {
    getSysState(params, valueType) {
      querySysSet(params).then((res) => {
        if (res.success) {
          let resConter = res.result
          if (resConter == 'enable') {
            this[valueType] = true
          } else {
            this[valueType] = false
          }
        } else {
          this.$antdMessage.warning(res.message)
        }
      })
    },
    switchChange(type) {
      let propObj = {
        key: '',
        value: '',
      }
      if (type == 'outValue') {
        propObj.key = 'outboundTaskCompleteBtnFlag'
      } else if (type == 'inValue') {
        propObj.key = 'inboundTaskCompleteBtnFlag'
      } else if (type == 'autoTurnOnValue') {
        propObj.key = 'productOrderAutoTurnOnFlag'
      }
      if (this[type]) {
        propObj.value = 'enable'
      } else {
        propObj.value = 'disable'
      }
      sysSetEdit(propObj).then((res) => {
        console.log('则是啥：', res)
        if (!res.success) {
          this.$antdMessage.warning(res.message)
        }
      })
    },
    changTab(indexLeft) {
      this.activeTab = indexLeft
      if (indexLeft == 0) {
        let outObj = {
          key: 'outboundTaskCompleteBtnFlag',
        }
        this.getSysState(outObj, 'outValue')
        let inObj = {
          key: 'inboundTaskCompleteBtnFlag',
        }
        this.getSysState(inObj, 'inValue')
      } else if (indexLeft == 1) {
        let aotuObj = {
          key: 'productOrderAutoTurnOnFlag',
        }
        this.getSysState(aotuObj, 'autoTurnOnValue')
      }
    },
    goBack() {
      // alert('提交成功')
      // this.$router.go(-1)
    },
  },
}
</script>
<style scoped lang='less'>
@import '~@/assets/less/public.less';
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.table-operations {
  margin-bottom: 16px;
}

.table-operations > button {
  margin-right: 8px;
}

.pubColor {
  font-size: 14px;
  color: #1890ff;
  cursor: pointer;
}
/deep/ .ant-card-body {
  height: calc(100vh - 140px);
  overflow: hidden;
  padding: 20px 16px;
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}

.cardBox {
  .flex(space-between, flex-start);
  .cardOne {
    width: 220px;
    margin-right: 2px;
    height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #fff;

    margin-top: 12px;
    box-sizing: border-box;
    .inputBox {
      box-sizing: border-box;
      padding: 20px 16px 0;
    }
  }
  .cardTwo {
    flex: 1;
  }
}
div.listBox {
  height: calc(100% - 20px);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  padding: 24px 0px;
  div.itemLeft {
    .flex(flex-start, center);
    height: 34px;
    cursor: pointer;
    box-sizing: border-box;
    padding: 0 16px;
    font-size: 14px;
    color: #444444;
  }
  div.actvieColor {
    color: #1890ff;
    background-color: #e6f7ff;
  }
}
a {
  margin: 0;
}
.stockBox {
  div.itemSet {
    box-sizing: border-box;
    padding: 16px;
    border-bottom: 1px dashed #f5f5f5;
    &:nth-last-child(1) {
      border-bottom: none;
    }
    div.setTop {
      .flex(space-between, center);
      margin-bottom: 12px;
      div.topLfet {
        .flex(flex-start, center);
        span.titleBorder {
          display: inline-block;
          width: 3px;
          height: 16px;
          background-color: #1890ff;
          margin-right: 5px;
        }

        span.titleStyle {
          font-size: 16px;
          font-weight: bold;
          color: #000000;
        }
      }

      div.topRight {
      }
    }

    div.setMeddle {
      box-sizing: border-box;
      padding: 0 10px;
      font-size: 14px;
      color: #333;
      margin-bottom: 10px;
    }

    div.setBot {
      box-sizing: border-box;
      padding: 0 10px;
      font-size: 14px;
      color: #333;
    }
  }
}
</style>
